package com.witfortos.kotlindemo.mvvm.view_model

import androidx.lifecycle.MutableLiveData
import com.witfortos.common.base.BaseViewModel
import com.witfortos.common.utils.JsonParam
import com.witfortos.kotlindemo.common.http.Req
import com.witfortos.kotlindemo.mvvm.data.News

class MainVm : BaseViewModel() {

    private val req by lazy {
        Req.getInstance()
    }
    var news = MutableLiveData<News>()

    fun getNews(pageNum: Int, type: Int) {
        launchGo({
            news.value = request {
                req.getNews(JsonParam().add("pageNum", pageNum).add("type", type).toString())
            };
        })
    }
}